Fix js_repl in-flight tool-call waiter race#11800
Merged
Conversation
This was referenced Feb 14, 2026
owenlin0
approved these changes
Feb 14, 2026
dce304d to
b269f97
Compare
fjord-oai
added a commit
that referenced
this pull request
Feb 14, 2026
## Summary Fixes a flaky/panicking `js_repl` image-path test by running it on a multi-thread Tokio runtime and tightening assertions to focus on real behavior. ## Problem `js_repl_can_attach_image_via_view_image_tool` in `/Users/fjord/code/codex-jsrepl-seq/codex-rs/core/src/tools/js_repl/mod.rs` can panic under single-thread test runtime with: `can call blocking only when running on the multi-threaded runtime` It also asserted a brittle user-facing text string. ## Changes 1. Updated the test runtime to: `#[tokio::test(flavor = "multi_thread", worker_threads = 2)]` 2. Removed the brittle `"attached local image path"` string assertion. 3. Kept the concrete side-effect assertions: - tool call succeeds - image is actually injected into pending input (`InputImage` with `data:image/png;base64,...`) ## Why this is safe This is test-only behavior. No production runtime code paths are changed. ## Validation - Ran: `cargo test -p codex-core tools::js_repl::tests::js_repl_can_attach_image_via_view_image_tool -- --nocapture` - Result: pass #### [git stack](https://github.com/magus/git-stack-cli) - 👉 `1` #11796 - ⏳ `2` #11800 - ⏳ `3` #10673 - ⏳ `4` #10670
git-stack-id: fjord/js_repl_seq---4hqv5xq_6zbgq0 git-stack-title: Fix js_repl in-flight tool-call waiter race
b269f97 to
6e0eee0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a race in
js_repltool-call draining that could leave an exec waiting indefinitely for in-flight tool calls to finish.The fix is in:
/Users/fjord/code/codex-jsrepl-seq/codex-rs/core/src/tools/js_repl/mod.rsProblem
js_repltracks in-flight tool calls per exec and waits for them to drain on completion/timeout/cancel paths.The previous wait logic used a check-then-wait pattern with
Notifythat could miss a wakeup:in_flight > 0notified().await)If
notify_waiters()happened between (2) and (3), the waiter could sleep until another notification that never comes.What changed
Arc<Notify>::notified_owned()instead of cloning notify and awaiting later.wait_for_exec_tool_callswait_for_all_exec_tool_callswait_for_exec_tool_calls_mapThis preserves existing behavior while eliminating the lost-wakeup window.
Test coverage
Added a regression test:
wait_for_exec_tool_calls_map_drains_inflight_calls_without_hangingThe test repeatedly races waiter/finisher tasks and asserts bounded completion to catch hangs.
Impact
git stack
1Fix js_repl view_image test runtime panic #117962Fix js_repl in-flight tool-call waiter race #118003Add feature-gated js_repl polling flow #106734Add optional js_repl isolation and vendored Node runtime #10670